import { RouteRecordRaw } from "vue-router";
import HomeView from "@/views/HomeView.vue";
import NoAuthView from "@/views/NoAuthView.vue";
import { ACCESS_ENUM } from "@/access/accessEnum";
import UserLayout from "@/layouts/UserLayout.vue";
import UserLoginView from "@/views/user/UserLoginView.vue";
import AddQuestionView from "@/views/question/AddQuestionView.vue";
import ManageQuestionView from "@/views/question/ManageQuestionView.vue";
import QuestionView from "@/views/question/QuestionView.vue";
import DoQuestionView from "@/views/question/DoQuestionView.vue";
import QuestionSubmitView from "@/views/question_submit/QuestionSubmitView.vue";
import AboutView from "@/views/user/AboutView.vue";
import ManageUserView from "@/views/user/ManageUserView.vue";
import AddUserView from "@/views/user/AddUserView.vue";
import ManageQuestionSubmitView from "@/views/question_submit/ManageQuestionSubmitView.vue";
import ManageQuestionCaseView from "@/views/question_case/ManageQuestionCaseView.vue";
import AddQuestionCaseView from "@/views/question_case/AddQuestionCaseView.vue";
import NotFoundView from "@/views/NotFoundView.vue";

export const routes: Array<RouteRecordRaw> = [
  {
    path: "/",
    name: "主页",
    component: HomeView,
  },
  {
    path: "/user",
    name: "用户",
    component: UserLayout,
    children: [
      {
        path: "/user/login",
        name: "用户登录",
        component: UserLoginView,
      },
    ],
    meta: {
      hiddenInMenu: true,
    },
  },
  {
    path: "/about",
    name: "关于我",
    component: AboutView,
    meta: {
      access: ACCESS_ENUM.USR,
      hiddenInMenu: true,
    },
  },
  {
    path: "/question",
    name: "浏览题目",
    component: QuestionView,
  },
  {
    path: "/question_submit",
    name: "题目提交列表",
    component: QuestionSubmitView,
  },
  {
    path: "/manage/question_submit",
    name: "管理提交记录",
    component: ManageQuestionSubmitView,
    meta: {
      access: ACCESS_ENUM.ADMIN,
    },
  },
  {
    path: "/view/question/:id",
    name: "在线做题",
    component: DoQuestionView,
    props: true,
    meta: {
      access: ACCESS_ENUM.USR,
      hiddenInMenu: true,
    },
  },
  {
    path: "/add/question",
    name: "创建题目",
    component: AddQuestionView,
    meta: {
      access: ACCESS_ENUM.ADMIN,
      hiddenInMenu: true,
    },
  },
  {
    path: "/update/question",
    name: "更新题目",
    component: AddQuestionView,
    meta: {
      access: ACCESS_ENUM.ADMIN,
      hiddenInMenu: true,
    },
  },
  {
    path: "/manage/question",
    name: "管理题目",
    component: ManageQuestionView,
    meta: {
      access: ACCESS_ENUM.ADMIN,
    },
  },
  {
    path: "/manage/user",
    name: "管理用户",
    component: ManageUserView,
    meta: {
      access: ACCESS_ENUM.ADMIN,
    },
  },
  {
    path: "/add/user",
    name: "创建用户",
    component: AddUserView,
    meta: {
      access: ACCESS_ENUM.ADMIN,
      hiddenInMenu: true,
    },
  },
  {
    path: "/update/user",
    name: "更新用户",
    component: AddUserView,
    meta: {
      access: ACCESS_ENUM.ADMIN,
      hiddenInMenu: true,
    },
  },
  {
    path: "/manage/question_case",
    name: "管理测试用例",
    component: ManageQuestionCaseView,
    meta: {
      access: ACCESS_ENUM.ADMIN,
      hiddenInMenu: true,
    },
  },
  {
    path: "/add/question_case",
    name: "新增测试用例",
    component: AddQuestionCaseView,
    meta: {
      access: ACCESS_ENUM.ADMIN,
      hiddenInMenu: true,
    },
  },
  {
    path: "/update/question_case",
    name: "更新测试用例",
    component: AddQuestionCaseView,
    meta: {
      access: ACCESS_ENUM.ADMIN,
      hiddenInMenu: true,
    },
  },
  {
    path: "/noAuth",
    name: "无权限",
    component: NoAuthView,
    meta: {
      hiddenInMenu: true,
    },
  },
  // 正确的 404 路由配置 ▼▼▼
  {
    path: "/:pathMatch(.*)*",
    name: "NotFound",
    component: NotFoundView,
    meta: { hiddenInMenu: true },
  },
];
